#!/usr/bin/env bash

if [ ! -d .venv ]; then
  if [ -z "$PYTHON" ]; then
    if [ ! -z "$(python3 --version | egrep '^Python 3.[6789]' 2>/dev/null)" ]; then
      # found python3.6 or better
      PYTHON=python3
    else
      # until we have better Linux distribution detection.
      PYTHON=python2
    fi
  fi

  virtualenv -p ${PYTHON} .venv
fi
. .venv/bin/activate
python -V
pip install -r requirements.txt

export SDIG=$(type -P sdig)

set -e
if [ "${PDNS_DEBUG}" = "YES" ]; then
  set -x
fi
exec ./runtests.py "$@"
